﻿package com.codingbros.fireworks.particles 
{
	
	import flash.display.Shape;
	
	import flash.geom.Point;
	
	/**
	 * ...
	 * @author ...
	 */
	public class RandomLineParticle extends Shape implements ILineParticle{
		
		private var currentPos:Point;
		private var lastPos:Point;
		
		private var color:uint;
		
		public function RandomLineParticle()
		{
			currentPos = new Point(0,0);
			lastPos = new Point(0,0);
		}
		
		public function init(color:uint):void 
		{
			this.color = color;
		};
		
		public function update():void
		{
			lastPos.x = currentPos.x;
			lastPos.y = currentPos.y;
			
			currentPos.x += -5 + Math.random() * 10;
			currentPos.y += -5 + Math.random() * 10;
		}
		
		public function draw():void
		{
			graphics.clear();
			graphics.lineStyle(1,color,0.5);
			graphics.moveTo(lastPos.x, lastPos.y);
			graphics.lineTo(currentPos.x, currentPos.y);		
		}
	}
}
